import scrapy


class HospitalSpider(scrapy.Spider):
    name = 'hospital'
    allowed_domains = ['yyk.99.com.cn']
    start_urls = ['https://yyk.99.com.cn/']

    def parse(self, response):
        # print(response,response.url,"***************************")
        lis = response.xpath(".//div[@class='home-rcont']/ul/li")
        # print("lis的长度是:",len(lis))
        item = {}
        for li in lis:
            # extract_first返回一个，extract返回列表,元素有多个的话使用这个
            item['content'] = li.xpath("./a/text()").extract_first()
            item['href'] = li.xpath("./a/@href").extract_first()
            # print(content)
            yield item #一个一个返回,不会中断方法的执行

